#
# Copyright 2010 Steve Leach
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
#

import unittest
import logging

def get_role_list(role_str):
	roles = []
	try:
		role_val = long(role_str)

		if role_val & 1:
			roles.append('Director')
		if role_val & 128:
			roles.append('PersonnelManager')
		if role_val & 8192:
			roles.append('HangarTake1')
		if role_val & 16384:
			roles.append('HangarTake2')
		if role_val & 2199023255552:
			roles.append('EquipmentConfig')
		if role_val & 9007199254740992:
			roles.append('StarbaseConfig')
	except ValueError:	
		logging.warning('Error parsing role string: ' + role_str)
	
	return roles

class TestUtils(unittest.TestCase):
	def test_simple_role_list(self):
		roles = get_role_list('472970324211834880')
		self.assertTrue('HangarTake1' in roles)
		self.assertFalse('Director' in roles)
	

if __name__ == '__main__':
    unittest.main()



